#include "StdAfx.h"
#include "GameStateStack.h"

// CTOR & DTOR
GameStateStack::GameStateStack(void)
{
	std::cout << "Creation de la GameStateStack" << std::endl;
}


GameStateStack::~GameStateStack(void)
{
	std::cout << "Destruction de la GameStateStack" << std::endl;
}


// Fonctions publiques
void GameStateStack::Set(AGameState *state)
{
	while (this->States.size() > 0)
	{
		Pop();
	}

	Add(state);
}

void GameStateStack::Add(AGameState *state)
{
	state->Initialize();
	this->States.push(state);
}

void GameStateStack::Pop()
{
	if (this->States.size() > 0)
	{
		this->States.top()->Destroy();
		this->States.pop();
	}
}

void GameStateStack::Update(float deltatime)
{
	if (this->States.size() > 0)
	{
		this->States.top()->Update(deltatime);
	}
}